home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000180_icon-group-sender _Mon Jun 20 09:34:17 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  914b

  1. Received: by cheltenham.cs.arizona.edu; Mon, 20 Jun 1994 12:14:22 MST
  2. Date: Mon, 20 Jun 94 09:34:17 PDT
  3. From: eric@star-semi.com (Eric Armstrong)
  4. Message-Id: <9406201634.AA28443@star-semi.com>
  5. To: icon-group@cs.arizona.edu
  6. Subject: anti-ugly contest
  7. Status: R
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9.  
  10. Help stamp out ugly icon code!
  11.  
  12. I'm getting better.  My first ugly version of the following routine,
  13. produced after much trial and error, required two (count 'em!) extra
  14. variables.  After some inspection, I managed to reduce it to:
  15.  
  16.     procedure squeeze(s)    
  17.        # Squeze out excess blanks from inside a string
  18.        s2 := ""
  19.        s ? {
  20.          while s2 ||:= tab(upto(" ")+1) do tab(many(" "))
  21.          s2 ||:= tab(0)
  22.          }
  23.        return s2
  24.     end
  25.  
  26. That cut the number of extra variables down to one (s2).
  27. Question: Is there an even more elegant way to do this that requires
  28. no extra variables?
  29.